package LawsonTransformJava.main;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import LawsonTransformJava.pgm.HR511;
import LawsonTransformJava.pgm.HR513;
import LawsonTransformJava.pgm.HR521;
import LawsonTransformJava.pgm.LP570;


public class LP570Main {

	/**
	 * @author edavis
	 */
	
	private static final String OUTPUTLOCATION = "z:/conversions/dataload";
	private static String envWhereClause = System.getenv("WHERECLAUSE");
	
	public static void main(String[] args) {
		if (args.length!=0) {
			usage();
		}
		try {
			Thread thread1 = null;
			File outFile = new File(OUTPUTLOCATION + "/TTRLOADCSV");
			// TODO Create Error output logic
			File errFile = new File(OUTPUTLOCATION + "/TTRERRORCSV");
			File convRpt = new File(OUTPUTLOCATION + "/LP521ConversionReport.txt");
	
			System.out.println("CLASSPATH=" + System.getenv("CLASSPATH"));
			System.out.println("WHERECLAUSE=" + envWhereClause);
			LP570 ttrDAO = null;
			ttrDAO = new LP570(outFile);
			
			if (ttrDAO!=null) {
				thread1 = new Thread(ttrDAO);
				//Set Where Clause from environment if found
				if (envWhereClause!=null)
					if (!envWhereClause.equals(""))
						ttrDAO.setWhereClause(envWhereClause);
//				ttrDAO.setWhereClause(" WHERE (to_char(r_date, 'yyyymmdd') > '20111231') and " +
//						"(to_char(r_date, 'yyyymmdd') < '20130101')");
				thread1.start();
			}
		} catch (SQLException sqle) {
			// Could not write properties file
			// Could not create output file
			System.out.println("SQLException: " + sqle);
		}
	}

	private static void usage() {
		System.err.println("Usage - HR521Main");
		System.exit(1);
	}
}
